//
//  GroupDetailsEditVC.m
//  SelfDriving
//
//  Created by apple on 16/4/7.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "GroupDetailsEditVC.h"

@interface GroupDetailsEditVC ()<TCResultNoneDelegate,TCResultGroupDelegate>
@property (weak, nonatomic) IBOutlet UITextView *textview;

@end

@implementation GroupDetailsEditVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _textview.layer.borderColor = colorBG.CGColor;
    _textview.layer.borderWidth = 0.5;
    self.automaticallyAdjustsScrollViewInsets = NO;
    
}
- (IBAction)submitAction:(UIBarButtonItem *)sender {
    if ([_textview.text trim].length == 0) {
        [SVProgressHUD showErrorWithStatus:@"请输入内容"];
        return;
    }
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setObject:_sessionid forKey:@"sessionid"];
    if (_type) {
        [dic setObject:_textview.text forKey:@"nickname"];
        [[BusinessService shareInstance]editNickname:dic success:^(id result) {
            [self.navigationController popViewControllerAnimated:YES];
        } failure:^(id result) {
            [SVProgressHUD showErrorWithStatus:result];
        }];
    }else{
        [dic setObject:_textview.text forKey:@"name"];
//        [[BusinessService shareInstance]gedit:dic success:^(id result) {
//            [self.navigationController popViewControllerAnimated:YES];
//        } failure:^(id result) {
//            [SVProgressHUD showErrorWithStatus:result];
//        }];
        [[ThinkChat instance]modifyConversation:_sessionid newName:_textview.text delegate:self];
     }
}
#pragma mark - TCResultNoneDelegate
-(void)tcResultGroup:(TCGroup *)itemG error:(TCError *)itemE{
    if (itemE == nil) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        [SVProgressHUD showErrorWithStatus:itemE.message];
    }
}

- (void)tcResultNoneError:(TCError *)itemE {
    if (itemE == nil) {
        [self.navigationController popViewControllerAnimated:YES];
    } else {
        [SVProgressHUD showErrorWithStatus:itemE.message];
    }
}


- (IBAction)backAction:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
